<?php

class graphic
{
    static function exif_type_str($file)
    {
        switch (exif_imagetype($file)) {
            case IMAGETYPE_GIF: return "IMAGETYPE_GIF";
            case IMAGETYPE_JPEG: return "IMAGETYPE_JPEG";
            case IMAGETYPE_PNG: return "IMAGETYPE_PNG";
            case IMAGETYPE_SWF: return "IMAGETYPE_SWF";
            case IMAGETYPE_PSD: return "IMAGETYPE_PSD";
            case IMAGETYPE_BMP: return "IMAGETYPE_BMP";
            case IMAGETYPE_TIFF_II: return "IMAGETYPE_TIFF_II";
            case IMAGETYPE_TIFF_MM: return "IMAGETYPE_TIFF_MM";
            case IMAGETYPE_JPC: return "IMAGETYPE_JPC";
            case IMAGETYPE_JP2: return "IMAGETYPE_JP2";
            case IMAGETYPE_JPX: return "IMAGETYPE_JPX";
            case IMAGETYPE_JB2: return "IMAGETYPE_JB2";
            case IMAGETYPE_SWC: return "IMAGETYPE_SWC";
            case IMAGETYPE_IFF: return "IMAGETYPE_IFF";
            case IMAGETYPE_WBMP: return "IMAGETYPE_WBMP";
            case IMAGETYPE_XBM: return "IMAGETYPE_XBM";
        }

        return "";
    }

    static function exif_data($file)
    {
        return exif_read_data($file, 0, true);
    }

    static function exif_thumbnail($file)
    {
        $image = exif_thumbnail($file, $width, $height, $type);
        if ($image!==false) {
            $fp = fopen($fname = md5_file($file).'.thumbnail', 'w+');
            fwrite($fp, $image, strlen($image));
            fclose($fp);
             echo "<img src=\"{$fname}\" title=\"{$file}\"/><br/>";
        }
    }
}

?>